<template></template>
<script setup lang="jsx">
import { h } from 'vue';
import { NButton, useNotification } from 'naive-ui';
import { useAppStore } from '@/store/modules/app.js';

const notification = useNotification();
const appStore = useAppStore();
function notice(options = {}) {
  $notification.info({
    title: options.title || '公告',
    description: '公告',
    content: () => <div vHtml={options.content}></div>,
    meta: `截止日期：${options.meta || '时间'}`,
  });
}
function notify(options = {}) {
  let markAsRead = false;
  const n = $notification.info({
    title: options.title || '通知',
    description: '通知',
    closable: false,
    content: () => <div vHtml={options.content}></div>,
    action: () =>
      h(
        NButton,
        {
          text: true,
          type: 'primary',
          onClick: () => {
            markAsRead = true;
            n.destroy();
          },
        },
        {
          default: () => '已读',
        },
      ),
  });
}
window['$notification'] = notification;
Object.defineProperty(window, '$notification', { configurable: false, writable: false });
window['$notice'] = notice;
Object.defineProperty(window, '$notice', { configurable: false, writable: false });
window['$notify'] = notify;
Object.defineProperty(window, '$notify', { configurable: false, writable: false });
</script>
